package com.game.chessgame;

public class Rook extends Piece {
    public Rook(Player player) {
        super(player);
    }

    @Override
    public char getSymbol() {
        return (player == Player.WHITE) ? 'R' : 'r';
    }

    @Override
    public boolean canMove(int fromX, int fromY, int toX, int toY, Piece[][] board) {
        int dx = Math.abs(toX - fromX);
        int dy = Math.abs(toY - fromY);
        if (dx == 0 && dy > 0) {
            return true; // 直线
        }
        if (dy == 0 && dx > 0) {
            return true; // 横线
        }
        return false;
    }
}